#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double db;

#define in read()
#define pii pair<int,int>
#define fi first
#define se second
#define FILE(x) freopen(x".in","r",stdin);\
	freopen(x".out","w",stdout);
#define pb push_back

int read(){
	int x = 0,sgn = 1;char ch = getchar();
	for(;!isdigit(ch);ch = getchar()) if(ch == '-') sgn = -1;
	for(;isdigit(ch);ch = getchar()) x = (x<<1)+(x<<3)+(ch^48);
	return x*sgn;
}

const int MAXN = 1e4+10;
const int M = 3247253;

int n,a[MAXN][110],dis[MAXN],num[M],to[MAXN],bac[MAXN];
bool v[MAXN];
char s[MAXN][110];
vector<int> G[MAXN];

int get(int *s){
	int val = 0;
	for(int i = 0;i < 26;i++) val = (val * 131ll + s[i]) % M;
	return val;
}

void print(int x){
	if(bac[x]) print(bac[x]);
	printf("%s\n",s[x]+1);
}

int main (){
#ifndef ONLINE_JUDGE
	freopen("1.in","r",stdin);
#endif
	while(scanf("%s",s[n+1]+1)==1){
		n++;
		int ls = strlen(s[n]+1);
		for(int j = 1;j <= ls;j++) a[n][s[n][j]-'a']++;
		num[get(a[n])] = n;
	}
	for(int i = 1;i <= n;i++){
		for(int c = 0;c < 26;c++){
			a[i][c]++;
			int y = num[get(a[i])];
			if(y) G[i].pb(y),to[y]++;
			a[i][c]--;
		}
	}
	queue<int> q; for(int i = 1;i <= n;i++) if(!to[i]) q.push(i),v[i] = 1,dis[i] = 1;
	while(q.size()){
		int x = q.front(); q.pop(); v[x] = 0;
		for(int y : G[x]){
			if(dis[x] + 1 > dis[y]){
				dis[y] = dis[x] + 1; bac[y] = x;
				if(!v[y]) q.push(y),v[y] = 1;
			}
		}
	}
	int ans = 0,pos = 0;for(int i = 1;i <= n;i++) if(dis[i] > ans) ans = dis[i],pos = i;
	printf("%d\n",ans);
	print(pos);
	return 0;
}

